using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyBullet : MonoBehaviour
{
    private BossController Boss;
    private Character Player;
    private float damage; // 子弹的伤害值
    void Start()
    {// 获取玩家的 PlayerController 组件
        Player= GameObject.FindGameObjectWithTag("Player").GetComponent<Character>();
        Boss = GameObject.FindGameObjectWithTag("Boss").GetComponent<BossController>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        damage = Boss.bossParameter.MeleeAttackValue;
        //并调用 TakeDamage 方法
        if (collision.CompareTag("Player"))
        {
            // 获取玩家的 PlayerController 组件，并调用 TakeDamage 方法
            if (Player != null)
            {
                Player.TakeDamage(damage*Boss.bossParameter.BossAttackMultiplier);
            }
            // 销毁子弹对象
            Destroy(gameObject);
        }
        else
        {
            if (collision.CompareTag("Walls"))
            {
                Destroy(gameObject);
            }
        }
    }
}
